package Code;

import javax.swing.JFrame;

import cs470.agent.PotentialFieldAgent;
import cs470.agent.ReallyDumbAgent;

public class Main {

	public static void main(String[] args) {
		//USAGE: port dumb|pf tankId
		if(args.length < 4) {
//			args = new String[]{FileHelper.getTextFromFile("C:\\config\\ip.config"), "50100", "pf", "0"};
			args = new String[]{"localhost", "50100", "pf", "0"};
			System.out.println(args[0]);
			//throw new IllegalArgumentException("Usage: <hostname> <port> dumb|pf tankId");
		}
		
		final int tankId = Integer.parseInt(args[3]);
		final BZRClient client = new BZRClient(args[0], Integer.parseInt(args[1]));
		if(args[2].equals("dumb")) {
			
			final ReallyDumbAgent agent = new ReallyDumbAgent(client);
			agent.add(client.getTanks().subList(0, 2));
			agent.run();
		} else if (args[2].equals("pf")) {
			final Environment environment = new Environment(client, true);
			final PotentialFieldAgent agent = new PotentialFieldAgent(client, environment, tankId);
			
			final JFrame jFrame = new JFrame("McNeill-Bailey Grid Filter");
			jFrame.setBounds(100, 100, environment.getWorldSize() + 20, environment.getWorldSize() + 20);
			jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			
			final DisplayPanel panel = new DisplayPanel(environment.getGrid());
			jFrame.add(panel);
			
			jFrame.setVisible(true);

			agent.run();

		}
	}
	
}
